home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 November / macformat-018.iso / Utility Spectacular / Developer / SAT / Collision][ ƒ / Collision][.c next >
Encoding:
C/C++ Source or Header  |  1994-07-26  |  1.5 KB  |  68 lines  |  [TEXT/KAHL]

  1. /********************************/
  2. /********** SAT Collision ][ ***********/
  3. /********************************/
  4.  
  5. /*A more advanced version of SAT Collision, demonstrating the use of callback routines*/
  6. /*(hit task) for collision handling. What has happened is that the apples switch between*/
  7. /*good and bad, and we are not supposed to eat one when it's bad.*/
  8.  
  9. /*program CollisionII;*/
  10.  
  11. #include "SAT.h"
  12. #include "Collision][.h"
  13.  
  14.  
  15.  
  16. main()
  17. {
  18.     SpritePtr    ignoreSp;
  19.     long        l;
  20.     Point        p;
  21.     int ignore;
  22.  
  23. /*Standard Inits.*/
  24.     MaxApplZone ();
  25.     FlushEvents (everyEvent - diskMask, 0 );
  26.     InitGraf (&thePort);
  27.     InitFonts ();
  28.     InitWindows ();
  29.     InitMenus ();
  30.     TEInit ();
  31.     InitDialogs (nil);        /* no restart proc */
  32.     InitCursor ();
  33.  
  34.     MoreMasters ();
  35.     MoreMasters ();
  36.  
  37.  
  38.     ConfigureSAT(true, kVPositionSort, kBackwardCollision, 32);
  39.     InitSAT(128, 129, 512, 322);
  40.  
  41.     InitMrEgghead();
  42.     InitApple();
  43.  
  44.     ShowWindow(gSAT.wind);
  45.     SelectWindow(gSAT.wind);
  46.     PeekOffscreen();
  47.  
  48.     GetMouse(&p);
  49.     ignoreSp = NewSprite(0, p.h, p.v, &SetupMrEgghead);
  50.     ignoreSp = NewSprite(0, 0, Rand(gSAT.offSizeV - 32), &SetupApple);
  51.  
  52.     HideCursor();
  53.  
  54. /* Get two channels if possible, since we use fairy long sounds. */
  55.     ignore = SATSoundInitChannels(2);
  56.  
  57.     while (!Button()) {
  58.         l = TickCount();
  59.         RunSAT(true);
  60. /*Start a new sprite once in a while.*/
  61.         if (Rand(40) == 1)
  62.             ignoreSp = NewSprite(0, 0, Rand(gSAT.offSizeV - 32), &SetupApple);
  63.         while (l > TickCount() - 2L) /*Maximize speed to 30 fps*/
  64.             ;
  65.     };
  66.     ShowCursor();
  67.     SATSoundShutup(); /*Always make sure the sound channel is de-allocated!*/
  68. }